#include<iostream>
using namespace std;
const int N = 1e4 + 10;
int f[N];
int dp[N];
int w[N], v[N];
int n, m, vol;
int find(int x)
{
	if (f[x] != x) {
		f[x] = find(f[x]);
	}
	return f[x];
}
int main()
{
	cin >> n >> m >> vol;
	for (int i = 1; i <= n; i++) {
		f[i] = i;
		cin >> v[i] >> w[i];
	}
	while (m--) {
		int a, b;
		cin >> a >> b;
		int pa = find(a);
		int pb = find(b);
		if (pa != pb) {
			f[pa] = pb;
			w[pb] += w[pa];
			v[pb] += v[pa];
		}
	}
	for (int i = 1; i <= n; i++) {
		if (f[i] == i) {
			for (int j = vol; j >= v[i]; j--) {
				dp[j] = max(dp[j], dp[j - v[i]] + w[i]);
			}
		}
	}
	cout << dp[vol] << endl;	
	return 0;
}